package com.qf.service;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.qf.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

/**
 * @author 千锋健哥
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private RestTemplate restTemplate;

    @Override
    //开启分布式事务
    @Transactional
    @LcnTransaction
    public void updateA() {
        //a账户扣款500元
        userMapper.updateA();

        //b账户加款500元
        String str = restTemplate.getForObject("http://localhost:8081/serviceB/update", String.class);

    }

}
